<template>
  <div class="goods-relevant">
    <div class="header">
      <i class="icon" />
      <span class="title">猜你喜欢</span>
    </div>
    <!-- 此处使用改造后的xtx-carousel.vue -->
    <RelevantList :list="list"></RelevantList>
  </div>
</template>

<script>
// 引入api
import { getRelevant } from "@/utils/Api/DetailApi";
// 引入渲染的组件
import RelevantList from "@/components/Detail/RelevantList.vue";
export default {
  props: ["id"],
  components: {
    RelevantList,
  },
  data() {
    return {
      list: [],
    };
  },
  mounted() {
    this.getRelevantData();
  },
  methods: {
    // 获取推荐商品的数据
    async getRelevantData() {
      let { data } = await getRelevant(this.id, 16);
      this.list = data.result;
    },
  },
};
</script>

<style lang="scss" scoped>
.goods-relevant {
  background: #fff;
  min-height: 460px;
  margin-top: 20px;
  .header {
    height: 80px;
    line-height: 80px;
    padding: 0 20px;
    .title {
      font-size: 20px;
      padding-left: 10px;
    }
    .icon {
      width: 16px;
      height: 16px;
      display: inline-block;
      border-top: 4px solid #27bb9a;
      border-right: 4px solid #27bb9a;
      box-sizing: border-box;
      position: relative;
      transform: rotate(45deg);
      &::before {
        content: "";
        width: 10px;
        height: 10px;
        position: absolute;
        left: 0;
        top: 2px;
        background: lighten(#27bb9a, 40%);
      }
    }
  }
}
</style>
